<template>
	<view>
		<q-field label="话题标题" v-model="dataForm.title" :required="true" placeholder="请填写话题标题"></q-field>
		<q-field label="话题简介" type="textarea" v-model="dataForm.introduction" :required="true" placeholder="请填写圈子话题简介"></q-field>
		<!-- 提交按钮 -->
		<view class="f-fixed">
			<q-button class="mt20" shape="circle" @click="onSubmit">提交</q-button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			dataForm: {
				topic_id: null,
				title: '',
				introduction: ''
			}
		};
	},
	onLoad(options) {
		this.dataForm.topic_id = options.topic_id;
	},
	methods: {
		onSubmit() {
			if (!this.dataForm.title) {
				uni.showToast({
					icon: 'none',
					title: '请填写话题标题'
				});

				return;
			}

			if (!this.dataForm.introduction) {
				uni.showToast({
					icon: 'none',
					title: '请填写话题简介'
				});

				return;
			}

			uni.showLoading({
				mask: true,
				title: '请稍后'
			});

			this.$H.post('discuss/userAdd',this.dataForm).then((res) => {
				if (res.code == 1) {
					uni.showToast({
						icon: 'success',
						title: '创建成功'
					});

					setTimeout(() => {
						uni.redirectTo({
							url: '/pages/topic/index?topic_id=' + this.dataForm.topic_id
						});
					}, 500);
				}
			});
		}
	}
};
</script>

<style lang="scss"></style>
